package bbs;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet(name = "productServlet", value = "/productServlet")
public class productServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1.获取表单元素（参数）
        String name = request.getParameter("name");
        String price = request.getParameter("price");
        String versions = request.getParameter("versions");
        String colour = request.getParameter("colour");
//        String list [] ={name,price,versions,colour} ;
        List<String> list = new ArrayList<>();
        list.add(name);list.add(price);list.add(versions);list.add(colour);
        request.setAttribute("list",list);
        request.getRequestDispatcher("index2.jsp").forward(request,response);
//            response.sendRedirect("./index2.jsp");
        }
    }